<template>
  <div class="mod-config" style="margin-top: 30px">
    <div v-if="showBlock">
      <el-table
        style="width: 100%;"
        :data="dataList"
        border
        v-show="tabType == 1"
        v-loading="dataListLoading"
      >
        <el-table-column
          type="index"
          width="80"
          header-align="center"
          align="center"
          label="序号"
        ></el-table-column>
        <el-table-column
          prop="pfxm"
          header-align="center"
          align="center"
          label="评分项目"
          show-overflow-tooltip
        >
          <template slot-scope="scope">
            <el-input v-model="scope.row.pfxm" placeholder="评分项目" />
          </template>
        </el-table-column>

        <el-table-column
          prop="fssz"
          header-align="center"
          align="center"
          label="分数设置"
          show-overflow-tooltip
        >
          <template slot-scope="scope">
            <el-input
              v-model="scope.row.fssz"
              placeholder="分数设置"
            />
          </template>
        </el-table-column>
        <el-table-column
          prop="pfsm"
          header-align="center"
          align="center"
          label="评分说明"
          show-overflow-tooltip
        >
          <template slot-scope="scope">
            <el-input
              v-model="scope.row.pfsm"
              placeholder="评分说明"
            />
          </template>
        </el-table-column>
        <el-table-column label="操作" width="60" header-align="center" align="center">
          <template slot="header">
            <el-button type="primary" icon="el-icon-plus" circle :disabled="zhuanxiangGzForm.mbname==null || zhuanxiangGzForm.description == null" @click="add()"></el-button>
          </template>
          <template slot-scope="scope">
            <el-button type="danger" icon="el-icon-minus" :disabled="zhuanxiangGzForm.mbname==null || zhuanxiangGzForm.description == null" circle @click="delBtn(scope.row)"></el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import {
    getzxgzZibiaoPage,
} from "@/api/hetongrenwu/zhuanxianggongzuo/zxgzmbcj";

export default {
  name: "zhongdianrwcj-form",
  components: {
  },
  props:{
    zhuanxiangGzForm:{
        mbname:null,
        description:null
    },
  },
  data() {
    return {
      showBlock: true,
      dataForm: {},
      tabType: "1",
      radio: "1",
      dataList: [],
      dataListLoading: false,
      dialogVisible: false,
      form: {},
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      mbId: "",
      mbName: "",
      pfmbid:"",
      type: 0,
      index: 1,

    };
  },
  watch: {
      zhuanxiangGzForm: {
      handler(newVal, oldVal) {
        if (newVal) {
          this.showBlock = false;
          this.$nextTick(res=>{
            this.showBlock = true;
          })
        }
      },
      immediate: true,
      deep: true,
    },
  },
  methods: {
    init(row, type) {
      //type=1为任务发起进来的，2为创建任务进来的
      this.form.mbName = row.mbname;
      this.dataList = [];
      this.form.mbId = row.id;

      this.mbName = row.mbname;

      this.getDataList();
    },
    getDataList() {

      this.dataListLoading = true;
        getzxgzZibiaoPage(
        Object.assign({
          pfmbid: this.pfmbid,
         /* type: this.radio,
          current: this.pageIndex,
          size: this.pageSize,
          bkhNumber: this.dataForm.bkhNumber,
          str: this.type,
          bkhName: this.dataForm.bkhName,
          khrZhiwu: this.dataForm.khrZhiwu,*/
        })
      ).then((response) => {
          console.log(response);
        this.dataList = response.data.data.records;
        this.totalPage = response.data.data.total;
      });
      this.dataListLoading = false;
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val;
      this.pageIndex = 1;
      this.getDataList();
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val;
      this.getDataList();
    },
    add() {

      this.index = this.dataList.length + 1
      var item = {
        mbName: "专项名称" + this.index,

        index: this.index,
      };

      this.dataList.push(item);
    },
    delBtn(row) {
      this.dataList.forEach((eles, i) => {
          if (row.index == eles.index) {
            this.dataList.splice(i, 1);
          }
      });
    },

  },
};
</script>

<style>

</style>
